# CMake Minimum version number required
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)

# Set Project Name
PROJECT(SoftWare)

# Set Config.h.in, Config.h Path
#configure_file (
#  "${PROJECT_SOURCE_DIR}/config/config.h.in"
#  "${PROJECT_BINARY_DIR}/config.h"
#  ) 

SET(CMAKE_C_FLAGS "-g -Wall -O2")

SET(CMAKE_CXX_FLAGS "-std=c++11 -g -Wall -02 ${CMAKE_CXX_FLAGS}")

SET(CMAKE_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/output)

if (DEBUG)
    SET(CMAKE_BUILD_TYPE "debug")
    ADD_DEFINITIONS(-DDEBUG_LEVEL=INFO)
else ()
    SET(CMAKE_BUILD_TYPE "release")
    ADD_DEFINITIONS(-DDEBUG_LEVEL=WARN)
endif ()

# Set Bin Path
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_OUTPUT_DIR}/bin)
MESSAGE(STATUS "Bin Path: " ${EXECUTABLE_OUTPUT_PATH})

SET(LIBRARY_OUTPUT_PATH ${CMAKE_OUTPUT_DIR}/lib)
MESSAGE(STATUS "Lib Path: " ${LIBRARY_OUTPUT_PATH})

SET(CONFIG_FILE_PATH ${PROJECT_SOURCE_DIR}/config)

# Only set default value, not set to config.h file
OPTION(CONFIG_COMMON_CRC "Use Crc Check Module" ON)
OPTION(CONFIG_COMMON_SOCKET "Use Socket Module" ON)
OPTION(CONFIG_COMMON_LINUX_SHM "Use linux share memory Module" ON)
OPTION(CONFIG_COMMON_LINUX_MSG "Use linux msg queue module" ON)
OPTION(CONFIG_COMMON_LINUX_SEM "Use linux shem" ON)
OPTION(CONFIG_COMMON_CYCLE_QUEUE "Use cycle queue Module" ON)
OPTION(CONFIG_COMMON_UART "Use Uart Module" ON)
OPTION(CONFIG_COMMON_MXML "Use XML Module" ON)
OPTION(CONFIG_COMMON_I2C "Use I2C Module" ON)
OPTION(CONFIG_COMMON_TIMER "Use Timer Module" ON)
OPTION(CONFIG_COMMON_LOGGER "Use LOGGER Module" ON)
OPTION(CONFIG_COMMON_THREAD_POOL "Use Thread Pool Module" ON)

CONFIGURE_FILE(
    "${CONFIG_FILE_PATH}/config.h.in"
    "${PROJECT_SOURCE_DIR}/public/config.h"
)


if (CONFIG_COMMON_MXML)
   ADD_SUBDIRECTORY(thrid_party/mxml) 
endif (CONFIG_COMMON_MXML)

ADD_SUBDIRECTORY(common)
MESSAGE(STATUS "Add directory common/src")

if (CMAKE_BUILD_TYPE MATCHES "debug")
   ADD_SUBDIRECTORY(unitest)
   MESSAGE(STATUS "Add directory unitest")
elseif (CMAKE_BUILD_TYPE MATCHES "release")	
   ADD_SUBDIRECTORY(src)
   MESSAGE(STATUS "Add directory src")
endif ()


